using System;
using System.Text;
using CLELCore;

namespace CLELCore.Executable
{
	public class SectionHeader
	{
		public const int SECTION_HEADER_SIZE = 0x28;
		public const int SECTION_HEADER_NAME_SIZE = 0x8;
				
		public const String TEXT_NAME = ".text\0\0\0";
		public const String RSRC_NAME = ".rsrc\0\0\0";
		public const String RELOC_NAME = ".reloc\0\0";

		private byte [] _name;
		private String _nameasstring;
		private int _virtual_size;
		private int _virtual_address;
		private int _size_of_raw_data;
		private int _pointer_to_raw_data;
		private int _pointer_to_relocations;
		private int _pointer_to_line_numbers;
		private short _number_of_relocations;
		private short _number_of_line_numbers;
		private int _characteristics;

		public byte[] Name
		{
			get
			{
				return _name;
			}
			set
			{	
				_name = value;
				String name = ASCIIEncoding.ASCII.GetString(_name);
				_nameasstring = name;
			}
		}

		public String NameAsString
		{
			get
			{
				return _nameasstring;
			}
		}

		public int VirtualSize
		{
			get
			{
				return _virtual_size;
			}
			set
			{
				_virtual_size = value;
			}
		}

		public int VirtualAddress
		{
			get
			{
				return _virtual_address;
			}
			set
			{
				_virtual_address = value;
			}
		}

		public int SizeOfRawData
		{
			get
			{
				return _size_of_raw_data;
			}
			set
			{
				_size_of_raw_data = value;
			}
		}

		public int PointerToRawData
		{
			get
			{
				return _pointer_to_raw_data;
			}
			set
			{
				_pointer_to_raw_data = value;
			}
		}

		public int PointerToRelocations
		{
			get
			{
				return _pointer_to_relocations;
			}
			set
			{
				_pointer_to_relocations = value;
			}
		}

		public int PointerToLineNumbers
		{
			get
			{
				return _pointer_to_line_numbers;
			}
			set
			{
				_pointer_to_line_numbers = value;
			}
		}

		public short NumberOfRelocations
		{
			get
			{
				return _number_of_relocations;
			}
			set
			{
				_number_of_relocations = value;
			}
		}

		public short NumberOfLineNumbers
		{
			get
			{
				return _number_of_line_numbers;
			}
			set
			{
				_number_of_line_numbers = value;
			}
		}

		public int Characteristics
		{
			get
			{
				return _characteristics;
			}
			set
			{
				_characteristics = value;
			}
		}

		public SectionHeader()
		{
		}
	}
}
